;(function(FormBase) {
    FormBase.Radio = FormBase.extend({
        constructor: function(singleId, mainContent, formConfig) {
            //不初始化监听事件
            this.inherit(singleId, mainContent, formConfig, true);
            //创建radio具体表单
            var t, inputStr = "";

            var dataArray = formConfig.dataArray;
            if (!dataArray || !dataArray.length) {
                //未配置数据
                console.error("no radio data array,please check....");
            } else {
                for (var i = 0; i < dataArray.length; i++) {
                    t = dataArray[i];
                    inputStr += '<div class="' + formConfig.radioClass + 'Container">' +
                        '<input type="radio" class="' + formConfig.radioClass + '" name="' + formConfig.id + 'Radio"  value="' + t.value + '" readonly="readonly" ><span>' + t.label + '</span></div>';
                }
                $(this.formEle).after(inputStr).addClass("hide");
            }
            this.initMouseListeners();
        },
        initMouseListeners: function() {
            var radios = document.getElementsByName(this.formEleId + "Radio");
            for (var i = 0; i < radios.length; i++) {
                if (document.all) { // IE
                    radios[i].attachEvent("onclick", this.clickAction.bindAsEventListener(this));
                } else {
                    radios[i].addEventListener("click", this.clickAction.bindAsEventListener(this), false);
                }
            }
        },
        clickAction: function(e) {
            var t2, tt = $(e.target || e.srcElement);
            t2 = $("#" + $(this.formEle).attr("id") + this.mainContent.errPostfix);
            if (this.clearErrorFocus && t2.length) t2.html("").addClass("hide");
            if (tt.hasClass("checked")) return;
            $("[name='" + this.formEleId + "Radio']").removeClass("checked");
            tt.addClass("checked");
            $(this.formEle).val(tt.val());
            delete this.mainContent[this.mainContent.formId + "errForm"][this.formEleId];
        }
    });
})(window.FormBase = window.FormBase || {})
